import { IsNumber, IsOptional, IsString } from 'class-validator'
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'
import { IsDateByUtils } from '@/common/decorator/utils.decorator'

@Entity('detail-page')
export class DetailPage {
  @PrimaryGeneratedColumn()
  @IsNumber()
  detailPageId: number

  /**
   * 公告标题
   */
  @Column({ nullable: true })
  @IsString()
  @IsOptional()
  detailPageTitle?: string

  /**
   * 公告日期
   */
  @Column({ nullable: true })
  @IsDateByUtils('YYYY-MM-DD')
  @IsOptional()
  detailPageDate?: string

  /**
   * 背景图片
   */
  @Column({ nullable: true })
  @IsString()
  @IsOptional()
  backGroundImage?: string

  /**
   * 主按钮图片
   */
  @Column({ nullable: true })
  @IsString()
  @IsOptional()
  mainButtonImage?: string

  /**
   * 次按钮图片
   */
  @Column({ nullable: true })
  @IsOptional()
  @IsString()
  subButtonImage?: string

  @CreateDateColumn()
  createdAt?: Date

  @UpdateDateColumn()
  updatedAt?: Date
}
